#include <cstdio>
#include <cstring>

#define DST "abcdegfhijklmnopq"

char a[18];
bool book[17];
long long cnt;

void dfs(int n) {
	if (n >= 17) {
		a[17] = '\0';
		if (!strcmp(a, DST)) {
			printf("%lld\n", cnt);
		}
		cnt++;
		return;
	}
	for (char i='a'; i<='q'; i++) {
		if (book[i-'a']) continue;
		book[i-'a'] = true;
		a[n] = i;
		dfs(n+1);
		book[i-'a'] = false;
	}
}

int main() {
	dfs(0);
	return 0;
}
